bitkeeper revision 1.1159.212.76 (4201eac5AlEp4jSQYKA8-oSf0N15pQ)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Thu, 3 Feb 2005 09:11:33 +0000 (09:11 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Thu, 3 Feb 2005 09:11:33 +0000 (09:11 +0000)
Add xmalloc_bytes() to the allocator API.
Signed-off-by: keir.fraser@cl.cam.ac.uk
xen/arch/x86/microcode.c
xen/arch/x86/pci-pc.c
xen/include/asm-x86/shadow.h
xen/include/xen/slab.h

index aa2966688e968e660d714314c62193fe776681d0..d811e7ed702e98ffc59d0b434c8e1bf9c11fcca2 100644 (file)
@@ -84,7 +84,7 @@
 #define DECLARE_MUTEX(_m) spinlock_t _m = SPIN_LOCK_UNLOCKED
 #define down(_m) spin_lock(_m)
 #define up(_m) spin_unlock(_m)
-#define vmalloc(_s) ((void *)xmalloc(u8[_s]))
+#define vmalloc(_s) xmalloc_bytes(_s)
 #define vfree(_p) xfree(_p)
 #define num_online_cpus() smp_num_cpus
 static inline int on_each_cpu(
index 09f562655b9c88e805a6ece49822c8df047684d8..177cc0a85196a4a6f9d12f42aeca79ae0e67aedc 100644 (file)
@@ -1036,7 +1036,7 @@ struct irq_routing_table * __devinit pcibios_get_irq_routing_table(void)
        if (ret & 0xff00)
                printk(KERN_ERR "PCI: Error %02x when fetching IRQ routing table.\n", (ret >> 8) & 0xff);
        else if (opt.size) {
-               rt = (struct irq_routing_table *)xmalloc(u8[sizeof(struct irq_routing_table) + opt.size]);
+               rt = xmalloc_bytes(sizeof(struct irq_routing_table) + opt.size);
                if (rt) {
                        memset(rt, 0, sizeof(struct irq_routing_table));
                        rt->size = opt.size + sizeof(struct irq_routing_table);
index fa518baff7c7a31841d7f613266c3ff8c5c6e1ce..9705e9ebfab9545ead6b338a4fa84e84f73d6c04 100644 (file)
@@ -616,8 +616,8 @@ static inline void set_shadow_status(
     {
         SH_LOG("Allocate more shadow hashtable blocks.");
 
-        extra = (struct shadow_status *)xmalloc(
-            u8[sizeof(void *) + (shadow_ht_extra_size * sizeof(*x))]);
+        extra = xmalloc_bytes(
+            sizeof(void *) + (shadow_ht_extra_size * sizeof(*x)));
 
         /* XXX Should be more graceful here. */
         if ( extra == NULL )
index 68d0ba00fb5971f2d5767210fb220bcdc7ee9266..d340651bacd2e68c871974c9403451c58c4622d0 100644 (file)
@@ -53,11 +53,17 @@ extern int xmem_cache_reap(void);
 
 extern void dump_slabinfo();
 
-/* Nicely typesafe for you. */
-#define xmalloc(_type) ((typeof(_type) *)_xmalloc(sizeof(_type)))
+/* Allocate space for typed object. */
+#define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type)))
+
+/* Allocate space for array of typed objects. */
 #define xmalloc_array(_type, _num)                 \
 ((_type *)(((_num) > (UINT_MAX / sizeof(_type))) ? \
            NULL : _xmalloc((_num) * sizeof(_type))))
+
+/* Allocate untyped storage. */
+#define xmalloc_bytes(_bytes) (_xmalloc(_bytes))
+
 #endif /* __ARCH_HAS_SLAB_ALLOCATOR */
 
 #endif /* __SLAB_H__ */